home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / comm / bbs / cit_src_AD08.lha / vorlister.c < prev    next >
C/C++ Source or Header  |  1998-12-17  |  3KB  |  111 lines

  1. /**
  2.  Vortex File Lister Version 1.00
  3. **/
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <libraries/dos.h>
  8. #include <dos.h>
  9. #include "ctdl.h"
  10. #include "vortex.h"
  11. #include <stdlib.h>
  12.  
  13. int sflag = FALSE;
  14.  
  15. struct FileInfoBlock *info;
  16. char *filename;
  17. void Process_File(char *name);
  18.  
  19. void main( int argc, char **argv);
  20. void main( int argc, char **argv)
  21.   {
  22.   int error, attr;
  23.   if( argc > 1 )
  24.     {
  25.     if( argv[argc-1][0] == '-' )
  26.       {
  27.       argc--;
  28.       if( argv[argc][1] == 'a' ||  argv[argc][1] == 'a')sflag = TRUE;
  29.       };
  30.     };
  31.   if( argc == 1 )
  32.     {
  33.     filename = "#?";
  34.     info  = (struct FileInfoBlock *)calloc(1,sizeof(struct FileInfoBlock));
  35.     attr = 1;          /* find all files not directories */
  36.     error = dfind(info,filename,attr);  /* get first one*/
  37.     while( error == 0 )
  38.       {
  39.       Process_File(info->fib_FileName);
  40.       error = dnext(info);
  41.       };
  42.     free(info);
  43.     }
  44.   else
  45.     {
  46.     while( argc > 1 )
  47.       {
  48.       argc--;
  49.       if( argv[argc][0] == '-' )
  50.         {
  51.         if( argv[argc][1] == 'a' ||  argv[argc][1] == 'A')sflag = TRUE;
  52.         }
  53.       else  Process_File(argv[argc]);
  54.       };
  55.     };
  56.   }
  57.  
  58. void Process_File(char *name)
  59.   {
  60.   ROOM_ENTRY_TYPE rec;
  61.   FILE *ip;
  62.   if( ( ip = fopen(name, "r") ) == NULL )
  63.     {
  64.     printf("Error: cannot open %s\n", name);
  65.     }
  66.   else
  67.     {
  68.     if( fread((void *)&rec, sizeof(ROOM_ENTRY_TYPE), 1, ip) != 1 )
  69.       {
  70.       printf("Error: could not read a record for file %s\n",name);
  71.       }
  72.     else
  73.       {
  74.       int node, nnodes;
  75.       int index;
  76.       nnodes = rec.index;
  77.       node   = ( nnodes < MAX_VORTEX_SIZE ) ? 0 : rec.next_slot;
  78.       printf("Vortex File: %s Index: %d Next: %d\n", name, rec.index, rec.next_slot );
  79.       printf("%20s %12s %10s %10s\n","Origin", "Src Id", "Date", "Time");
  80.       while( nnodes-- )
  81.         {
  82.         if( sflag == TRUE )
  83.           {
  84.           printf( "%20s %12s %10s %10s %d\n",
  85.           rec.msg_entry[node].mborig, rec.msg_entry[node].mbsrcId,
  86.           rec.msg_entry[node].mbdate, rec.msg_entry[node].mbtime,
  87.           node);
  88.           }
  89.         else
  90.           {
  91.           for( index=0; index < MAX_VORTEX_SIZE; index++ )
  92.             {
  93.             if( index == node ) continue;
  94.             if( rec.msg_entry[node].mbsrcId[0] )
  95.               if( rec.msg_entry[index].mbsrcId[0] )
  96.                 if( strcmp(rec.msg_entry[node].mbsrcId, rec.msg_entry[index].mbsrcId) == 0 )
  97.               {
  98.               printf( "%20s %12s %10s %10s %d\n",
  99.               rec.msg_entry[node].mborig, rec.msg_entry[node].mbsrcId,
  100.               rec.msg_entry[node].mbdate, rec.msg_entry[node].mbtime,
  101.               node);
  102.               };
  103.              };
  104.            };
  105.         node = ( node + 1 ) % MAX_VORTEX_SIZE;
  106.         };
  107.       };
  108.     fclose(ip);
  109.     };
  110.   }
  111.